#define _CRT_SECURE_NO_WARNINGS 1  
struct ListNode* mergeTwoLists(struct ListNode* l1, struct ListNode* l2) {
    struct ListNode* tail, * head;
    tail = head = (struct ListNode*)malloc(sizeof(struct ListNode));
    tail->next = NULL;
    while (l1 && l2)
    {
        if (l1->val < l2->val)
        {
            tail->next = l1;
            tail = l1;
            l1 = l1->next;
        }
        else
        {
            tail->next = l2;
            tail = l2;
            l2 = l2->next;
        }
    }
    if (l1 == NULL)
    {
        tail->next = l2;
    }
    if (l2 == NULL)
    {
        tail->next = l1;
    }
    struct ListNode* newhead = head->next;
    free(head);
    head = NULL;
    return newhead;
}